<template>
	<view>
		<view class="content">
			<view class="cont_1">
				<view class="info_flex" @click="gouserinfo">
					<view class="info_l">
						<image :src="userinfo.headImg?userinfo.headImg : '../../static/login.png'" mode=""></image>
					</view>
					<view class="info_r" v-if="userinfo.nickName">
						<view class="tname">{{userinfo.nickName}}</view>
						<view class="tphone">{{userinfo.phone}}</view>
					</view>
					<view class="info_r" v-else>
						<view class="tname">点击登录</view>
						<view class="tphone">为给您提供更好的服务请授权登录</view>
					</view>
				</view>
				<view class="btn">
					<button open-type="contact">客服咨询</button>
					<!-- 登录/注册 -->
				</view>
			</view>
			<swipergo :swiperid="swiperid" :upHeight="244"></swipergo>
			<view class="img_flex">
				<view class="item_img" :class="`item_img`+index" v-for="(item,index) in contlist" :key="index"
					@click="goPage(item.id)">
					<image class="imgs" :src="item.path" mode=""></image>
					<view class="text">
						{{item.t}}
					</view>
				</view>
				<button :plain='true' class="btns" open-type="contact"></button>
			</view>
			
		</view>
		<view class="bot">
			<view class="bot_flex" @click="goPage(5)">
				<view class="bot_flex_l">
					<image src="../../static/my6.png" mode=""></image>
					<view class="ts">
						关于我们
					</view>
				</view>
				<uni-icons type="right" size="20"></uni-icons>
			</view>
			
			<view class="bot_flex" @click="goPage(6)">
				<view class="bot_flex_l">
					<image src="../../static/my5.png" mode=""></image>
					<view class="ts">
						联系我们
					</view>
				</view>
				<uni-icons type="right" size="20"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script>
	import { getuserInfo} from '@/common/http.api.js';
	export default {
		data() {
			return {
				swiperid:8,
				token:uni.getStorageSync('token'),
				text: '',
				contlist: [{
						id: 1,
						path: require('../../static/my1.png'),
						t: '我的收藏'
					},
					{
						id: 2,
						path: require('../../static/my2.png'),
						t: '我的权益'
					},
					{
						id: 3,
						path: require('../../static/my3.png'),
						t: '动态通知'
					},
					{
						id: 4,
						path: require('../../static/my4.png'),
						t: '联系客服'
					}
				],
				userinfo:{},
			};
		},
		onLoad() {
		},
		onShow() {
			if(uni.getStorageSync('token')){
				getuserInfo().then(res=>{
					if(res.code == 200){
						this.userinfo = res.data
					}
				})
			}
		},
		methods: {
			gouserinfo(){
				if(uni.getStorageSync('token') !=''){
					uni.navigateTo({
						url:'/pages/my/userinfo'
					})
				}else{
					uni.navigateTo({
						url:'/pages/my/login'
					})
				}
			},
			goPage(id){
				if(id == 1){
					if(uni.getStorageSync('token') !=''){
						uni.navigateTo({
							url:'/pages/my/mysc'
						})
					}else{
						uni.navigateTo({
							url:'/pages/my/login'
						})
					}
					
				}else if(id == 2 || id == 5 || id == 6){
					uni.navigateTo({
						url:`/pages/my/mytext?id=${id}`
					})
				}else if(id == 3){
					uni.navigateTo({
						url:'/pages/my/notice'
					})
				}
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #F0F0F1;
	}

	.content {
		background-color: #fff;
		padding: 68rpx 24rpx 0rpx;
		box-sizing: border-box;

		.cont_1 {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.info_flex {
				display: flex;
				align-items: center;

				.info_l {
					width: 120rpx;
					height: 120rpx;

					image {
						width: 120rpx;
						height: 120rpx;
						border-radius: 60rpx;
					}
				}

				.info_r {
					margin-left: 20rpx;
					line-height: 54rpx;
					.tname {
						font-size: 34rpx;
					}
					.tphone {
						font-size: 26rpx;
					}
				}
			}

			.btn {
				button {
					width: 160rpx;
					height: 76rpx;
					background-color: #FF6161;
					color: #fff;
					font-size: 26rpx;
					text-align: center;
					line-height: 76rpx;
				}
					// width: 160rpx;
					// height: 66rpx;
					// background-color: #022B5F;
					// color: #fff;
					// font-size: 24rpx;
					// text-align: center;
					// line-height: 66rpx;
					// border-radius: 38rpx;
			}
		}

		.swiper1 {
			width: 702rpx;
			margin: 40rpx auto;

			.swiper {
				width: 702rpx;
				height: 224rpx;

				.items_sw {
					width: 702rpx;
					height: 224rpx;

					image {
						width: 100%;
						height: 224rpx;
					}
				}
			}
		}



		.img_flex {
			display: flex;
			height: 244rpx;
			width: 100%;
			padding:0rpx 24rpx;
			justify-content: space-between;
			box-sizing: border-box;
			.item_img {
				background-color: #fff;
				width: 122rpx;
				height: 122rpx;
				border-radius: 50%;
				text-align: center;

				.imgs {
					width: 64rpx;
					height: 64rpx;
					margin-top: 29rpx;
				}
			}

			.item_img0 {
				background-color: rgba(246,145,138,0.2);
			}

			.item_img1 {
				background-color: rgba(245,58,103,0.2);
			}

			.item_img2 {
				background-color: rgba(0,97,178,0.2);
			}

			.item_img3 {
				background-color:rgba(35,246,228,0.2);
			}
			.text {
				margin-top: 50rpx;
				font-size: 30rpx;
			}
			.btns{
				position: absolute;
				width: 122rpx;
				height: 122rpx;
				right: 48rpx;
				border: none;
			}
		}


	}
	.bot{
		background-color: #F8F8F8;
		padding: 50rpx 24rpx 60rpx;
		box-sizing: border-box;
		.bot_flex{
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #fff;
			padding: 0rpx 24rpx;
			margin-bottom: 20rpx;
			height: 88rpx;
			.bot_flex_l{
				display: flex;
				align-items: center;
				image{
					width: 45rpx;
					height: 46rpx;
				}
				.ts{
					margin-left: 20rpx;
					font-size: 30rpx;
				}
			}
		}
	}

</style>